package com.ebuy.shopping.service;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.ebuy.shopping.mapper.NewsMapper;
import com.ebuy.shopping.model.News;
/**
 * 
 * @ClassName: NewsService
 * @Description: TODO
 * @author songwen
 * @date 2017年8月10日 上午10:42:34
 * 
 */
@Service
public class NewsService implements INewsService {
	@Autowired
	private NewsMapper newsMapper;

	@Override
	public News load(int id) throws Exception {
		return newsMapper.selectByPrimaryKey(id);

	}
	// 添加新闻
	@Override
	public int add(News news) throws Exception {

		return newsMapper.insert(news);
	}

	@Override
	public int update(News news) throws Exception {
		return newsMapper.updateByPrimaryKey(news);

	}

	// 分页查询新闻
	@Override
	public List<News> getNewsPage(Map<String, Object> map) {

		return newsMapper.selectNewsPage(map);
	}

	@Override
	public int delete(int id) throws Exception {

		return newsMapper.deleteByPrimaryKey(id);

	}

}
